package com.wy.controller;

import com.wy.Service.DengjService;
import com.wy.Service.ParkService;
import com.wy.pojo.Dengj;
import com.wy.pojo.Park;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/park")
@CrossOrigin
public class ParkController {
    @Resource
    private ParkService parkService;

    String msg;
    @GetMapping("/list")
    public List<Park>seach(Integer parentid){
        return parkService.searchidAll(parentid);
    }

    @GetMapping("/delete")
    public String delete(Integer id){
        try{
            parkService.del(id);
            msg="删除成功";
        }catch (Exception e){
            msg="删除失败";
        }
        return msg;
    }

    @GetMapping("/add")
    public String add(Park park){
        try{
            park.setState(1);
            parkService.add(park);
            msg="添加成功";
        }catch (Exception e){
            msg="添加失败";
        }
        return msg;
    }
}
